﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SearchData
{
    public partial class frmShowDetails : Form
    {
        public frmShowDetails()
        {
            InitializeComponent();
        }

        internal void FillGrid(DataSet ds)
        {
            try
            {
                if (ds!=null && ds.Tables.Count>0 && ds.Tables[0].Rows.Count>0)
                {
                    grdDetails.DataSource = ds.Tables[0];
                }
                else
                {
                    MessageBox.Show("No Record Exists for the selected table.");
                    this.Close();
                }
               
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void frmShowDetails_Resize(object sender, EventArgs e)
        {
            ArrangeGrid();
        }

        private void ArrangeGrid()
        {
            grdDetails.Width = this.Width;
            grdDetails.Height = this.Height;
            int colCounts = grdDetails.Columns.Count;
            for (int i = 0; i < colCounts ; i++)
            {
                grdDetails.Columns[i].Width = (this.Width-55) / colCounts;
            }
        }

        private void frmShowDetails_Load(object sender, EventArgs e)
        {
            ArrangeGrid();
        }
    }
}
